package cn.hongyu.service.impl;

import cn.hongyu.dao.UserDao;
import cn.hongyu.domain.User;
import cn.hongyu.service.UserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    public boolean save(User user) {
        return userDao.save(user);
    }

    @Override
    public boolean delete(Integer uuid) {
        return userDao.delete(uuid);
    }

    @Override
    public boolean update(User user) {
        return userDao.update(user);
    }

    @Override
    public User findById(Integer uuid) {
        User user = userDao.findById(uuid);
        //System.out.println(user);
        return user;
    }

    @Override
    public PageInfo<User> findAll(int page,int size) {
        //分页组件
        PageHelper.startPage(page,size);
        List<User> userList = userDao.findAll();
        return new PageInfo<User>(userList);
    }

    @Override
    public User login(String userName, String password) {
        return userDao.findByUserNameAndPassword(userName,password);
    }
}
